home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6555 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.2 KB

  1. Path: qualcomm.com!usenet
  2. From: nabbasi@qualcomm.com (Nasser Abbasi)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Is there a tool for exception-checking?
  5. Date: 9 Feb 1996 10:30:09 GMT
  6. Organization: QUalcomm Inc.
  7. Message-ID: <4ff7nh$epm@qualcomm.com>
  8. References: <311B1359.41B1@ids-scheer.de>
  9. NNTP-Posting-Host: annex-p26.qualcomm.com
  10. X-Newsreader: WinVN 0.90.4
  11.  
  12. In article <311B1359.41B1@ids-scheer.de>, Thomas Trenz <trenz@ids-scheer.de> says:
  13. >
  14. >Hi folks,
  15. >
  16. >Is there a tool, that can check a projects throw-statements.
  17. >For example:
  18. >
  19. >class A
  20. >{
  21. >public:
  22. >
  23. >  int f () throw (B, C);
  24. >  int g () throw (B);
  25. >};
  26. >
  27. >
  28. >int A :: f () throw (B, C)
  29. >{
  30. >  // some code that can throw either B or C...
  31. >}
  32. >
  33. >int A :: g () throw (B)
  34. >{
  35. >  f();
  36. >}
  37. >
  38. >
  39. >Raising an exception of type C in f() causes an runtime-
  40. >error in g(), because g guarantees, that it only raises
  41. >exceptions of type B.
  42. >
  43. >So is there any tool, that can find these pitfalls?
  44. >
  45. >Thanx in advance...
  46. >
  47.  
  48. First , I do not know of any such tool myself.
  49.  
  50. I have not used C++ exceptions much (compiler we use do not support
  51. them for the target we have), but it seems to me that no tool
  52. really is needed here. 
  53.  
  54. A function will raise the SUM of the following exceptions:
  55. 1. all possible exceptions it raises itself.
  56. 2. all possible exceptions raised by each function call inside it.
  57.  
  58. Item 1 above is easy to find , since you are writing that function, or
  59. can be found by searching for all throw statments in the function.
  60.  
  61. Item 2 can by found by making a list that contains each function 
  62. called from that function, then getting the defintion of that 
  63. function to see what exceptions the function can raise, and by 
  64. the magic of cut/paste you have the list of total exceptions needed.
  65.  
  66. The only problem I see here (which is why you probably asked the question)
  67. is that one might miss locating all function calls made by just doing
  68. visual inspection in the code. Have you tried to look at the compiler
  69. listing file, some compilers can generate listing showing symbols 
  70. referenced in each function, and type of symbole. This might help. 
  71. But it seems to me just looking and the code should be enough.
  72.  
  73. After rambling all of this, I am not sure now I was of any help to you.
  74.  
  75. Nasser
  76.